//这个文件专门用于创建整个应用的路由器
import VueRouter from "vue-router"
//引入组件
import Forum from '../pages/Forum.vue'
import Me from '../pages/Me.vue'
import ForumDetail from '../pages/ForumDetail.vue'
import Login from '../pages/Login.vue'
import Register from '../pages/Register.vue'
const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

//创建并暴露一个路由器
export default new VueRouter({
    routes:[
        {
            path:'/',
            component:Login
        },
        {
            path:'/Login',
            name:'login',
            component:Login
        },
        {
            path:'/Register',
            component:Register
        },
        {
            path:'/Forum',
            component:Forum
        },
        {
            path:'/Attention',
            component:()=>import('../pages/Attention.vue')
        },
        {
            path:'/Me',
            component:Me,
            redirect:'/Me/MyCollect',
            children:[
                {
                    path:'MyPost',
                    component:()=>import('../components/MePart/MyPost.vue')
                },
                {
                    path:'MyCollect',
                    component:()=>import('../components/MePart/MyCollect.vue')
                },
                {
                    path:'MyAttention',
                    component:()=>import('../components/MePart/MyAttention.vue')
                }
            ]
        },
        {
            path:'/ForumDetail',
            name:'forumDetail',
            component:ForumDetail
        },
        {
            path:'/empty',
            component:()=>import('../pages/empty.vue')
        },
        {
            path:'/AddForum',
            component:()=>import('../pages/AddForum.vue')
        },
        {
            path:'/CommentDetail',
            name:'commentDetail',
            component:()=>import('../pages/CommentDetail.vue')
        },
        {
            path:'/UserInfo',
            name:'userInfo',
            component:()=>import('../pages/UserInfo.vue')
        },
    ],
    mode:'history'
})